#include <BustaNetClient.h>
Public Member Functions | |
BustaNetClient () | |
Constructor. | |
~BustaNetClient () | |
Destructor. | |
char * | init () |
Initializes the client and prepares it for connection. | |
char * | connect (char *IP, Uint16 serverPort) |
Connects to a server using a given port. | |
void | disconnect () |
Disconnects from the server. | |
void | flushSocket () |
Flushes the socket connection to the server of all data. | |
int | getClientID () |
Returns the network identification number of the client. | |
int | getMaxPlayers () |
Returns the maximum number of players the server allows. | |
BustaModelMPGameState * | getMPGS () |
Returns game state information about opponent players. | |
int | getPlayerCount () |
Returns the number of players on the server. | |
BustaNetMsgQ * | getPriorityQ () |
Returns the server priority message queue. | |
BustaNetMsgQ * | getSandwichQ () |
Returns the special sandwich queue. | |
char * | getServerName () |
Returns the name of the server connected to. | |
MPJoinResponse * | joinGame (char *playerName) |
Joins the server multiplayer game. | |
bool | processNet () |
Handles all incoming network data. | |
void | sendCharSelect (BustaModelCharacter character) |
Sends character selection of player. | |
void | sendCursor (BustaModelPosition *cursor) |
Sends current character selection cursor position of player. | |
void | sendGameOver () |
Notifies the server that the player has lost the game. | |
void | sendOpponentViewReq (int opponentID) |
Tells the server which opponent the player wishes to view. | |
void | sendPing () |
Sends a simple response request to the server. | |
void | sendReady () |
Sends a ready message to the server. | |
void | sendSandwich (int opponentID, SpecialSandwich sandwich) |
Sends a spcial sandwich across the network. | |
void | sendState (BustaModelGameState *gs) |
Sends player's game state to the server. |
Busta'Sandwich Client for networked multiplayer games.
|
Constructor. Initializes variables. A multiplayer gamestate is NOT constructed at this point. Construction of the MPGameState is left to the joinGame() method; joinGame() receives the required information about the server from the server which allows it to know how to construct the MPGameState.
|
|
Destructor. Close any open connections and shutdown SDLNet |
|
Connects to a server using a given port. The client initializes a TCP connection with the server on the specified port.
|
|
Disconnects from the server. The connection between the server and client is disconnected. Subsequent connections may be made using the client. The multiplayer gamestate is also freed from memory. |
|
Flushes the socket connection to the server of all data. Empties the socket queue of all data. You may want to do this if you suspect an error in parsing the data from the socket. For instance, if the client is 1 byte off in pulling data from the socket, all the data will be corrupt. It may be better to flush the entire socket and wait for new messages from the server altogether. |
|
Returns the network identification number of the client. All clients in a multiplayer game are given a unique network identification number. This is the means by which clients can distinguish other clients from one another. This method returns the client identification number assigned to this client. By default it is set to -1, and it is reset to -1 when disconnected from a server. When the client has successfully joined a network game the server will assign the client a new number.
|
|
Returns the maximum number of players the server allows. Returns the number of players that the server allowed as a maximum.
|
|
Returns game state information about opponent players. Returns a pointer to a BustaModelMPGameState containing information about opponent players. The MPGameState is only instantiated after the client has properly connected and joined a game on a server.
|
|
Returns the number of players on the server. Returns the number of players that are on the server that the client is connected to. This is the number of other players on the server, which does not include the client in the count.
|
|
Returns the server priority message queue. Returns the queue of messages from the server. These messages do not cover special sandwiches or game states.
|
|
Returns the special sandwich queue. Returns the queue of special sandwiches sent between players in a multiplayer game.
|
|
Returns the name of the server connected to. Returns the name of the server the client is currently connected to.
|
|
Initializes the client and prepares it for connection. Initializes SDLNet. Relays any error message back.
|
|
Joins the server multiplayer game. This method attempts to connect the client to the multiplayer game hosted by the server. The client should be connected to the server before running this method. The multiplayer gamestate is instantiated after calling this method if the join was successful.
|
|
Handles all incoming network data. Processes all data currently queued on the TCP socket. The data is partitioned out into three message containers. Each of these three message containers is accessible through an accompanying accessor method.
|
|
Sends character selection of player. Sends the character selection by the player to the server to be sent to all connected players.
|
|
Sends current character selection cursor position of player. Sends the current position of the player's cursor during multiplayer character selection.
|
|
Notifies the server that the player has lost the game. A message is sent to the server to notify it that the player has lost in the current multiplayer game. |
|
Tells the server which opponent the player wishes to view. A message is sent to the server to tell it which opponent the player wishes to have a detailed view of. The detailed view contains information to display the entire screen of the opponent rather than limited brief data.
|
|
Sends a simple response request to the server. Sends a response request to the server. This is useful when the client is unsure whether or not the server is still responding to the client or connected at all. The server follows up with a 'Pong' response. |
|
Sends a ready message to the server. Sending a ready message to the server indicates that the client is ready to begin the multiplayer game. The ready state is visible to all other clients and is used to determine when the server should transition from the accepting connections state. |
|
Sends a spcial sandwich across the network. A special sandwich is sent from the player to an opposing player.
|
|
Sends player's game state to the server. A BustaModelGameState is converted into structs without pointers to form a packet to send to the server. It makes two sends, a packet identifier message, and the netGameState data packet.
|